package com.tanjun.publicservice.web.controller;

import com.tanjun.common.enums.FileTypeEnum;
import com.tanjun.common.model.R;
import com.tanjun.publicservice.web.service.UploadFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import static com.tanjun.common.constants.UrlConstant.URL_AUTH.OPEN;

@RestController
public class UploadFileController {
    @Autowired
    private UploadFileService uploadFileService;

    @PostMapping(OPEN + "/upload")
    public R<String> upload(@RequestParam("file") MultipartFile file, @RequestParam("type") FileTypeEnum fileTypeEnum) {
        uploadFileService.upload(file, fileTypeEnum);
        return R.OK("");
    }
}
